<?php

class AdminProvider
{
    public function GetCategories()
    {
        $db = Context::DB();
        if($db->connectDatabase())
            print_r($db->query("SELECT * FROM Categories"));
    }
    public function GetProducts()
    {
        $db = Context::DB();
        if($db->connectDatabase())
            print_r($db->query("SELECT * FROM Products"));
    }
    public function GetOtherInfo()
    {
        $db = Context::DB();
        if($db->connectDatabase())
            print_r($db->query("SELECT * FROM OtherInfo"));
    }
    function GetNews(){
        $db = Context::DB();
        if($db->connectDatabase())
            print_r($db->query("SELECT * FROM News"));
    }
    function GetContactInfo(){
        $db = Context::DB();
        if($db->connectDatabase())
            print_r($db->query("SELECT * FROM ContactInfo"));
    }
    function GetUsers(){
        $db = Context::DB();
        if($db->connectDatabase())
            print_r($db->query("SELECT * FROM Admin"));
    }

    function addToSlider($productId){
        $db = Context::DB();
        if($db->connectDatabase()) {
            $db->prepareQuery("INSERT INTO Slider VALUES (null,$productId)");
            return true;
        }
        return false;

    }
    function GetAdv(){
        $db = Context::DB();
        if($db->connectDatabase())
            print_r($db->query("SELECT * FROM Advert"));
    }
    function  GetLinks(){
        $db = Context::DB();
        if($db->connectDatabase())
            print_r($db->query("SELECT * FROM Auto"));
    }

    function GetRoles(){
        $db = Context::DB();
        if($db->connectDatabase())
            print_r($db->query("SELECT * FROM Role"));
    }

    function getSliderSlides()
    {
        $db = Context::DB();
        if($db->connectDatabase())
            print_r($db->query("SELECT * FROM Slider JOIN Products ON Products.Id = Slider.ProductId"));
    }

    function removeSlide($id)
    {
        $db = Context::DB();
        if($db->connectDatabase())
            print_r($db->prepareQuery("DELETE FROM Slider WHERE Slider.ProductId = $id"));
    }
    function GetCurrentProduct($id)
    {
        $db = Context::DB();
        if($db->connectDatabase())
            print_r($db->query("SELECT * FROM Products WHERE Products.Id = $id"));
    }
    function GetNewProduct()
    {
        $db = Context::DB();
        if($db->connectDatabase())
            print_r($db->query("SELECT * FROM Products ORDER BY Products.Id LIMIT 4 "));
    }
    function GetProductByCategory($id)
    {
        $db = Context::DB();
        if($db->connectDatabase())
            print_r($db->query("SELECT * FROM Products WHERE Products.CategoryId= $id"));
    }



}
